<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>表单验证</title>
</head>
<body>
    用户名：<input type="text">
    <span></span>
    <script>
        const s=document.querySelector('[type=text]')
        s.addEventListener('blur',function(){
            document.querySelector('span').innerHTML=/^[a-zA-Z0-9-_]{6,}$/.test(s.value)
            
        })
    </script>
</body>
</html>